
--[[

    slimui - Copyright (c) 2011 atom0s, All rights reserved.

    See Copyright notice in slimui.lua
    
]]--

class 'Picture: Object' { ... };

----------------------------------------------------------------------------------
-- func: Picture.__init__
-- desc: Constructor called when this object is first created.
----------------------------------------------------------------------------------
function Picture.__init__( self )
    Object.__init__( self );
end

----------------------------------------------------------------------------------
-- func: Picture:Create
-- desc: Creates a new picture object.
----------------------------------------------------------------------------------
function Picture:Create( )
    self._object = createPicture( );

    if self._object == nil then
        slimui:err( 'Picture:Create failed to initialize a new object.' );
    end
    
    return self;
end

----------------------------------------------------------------------------------
-- func: Picture:Bind
-- desc: Binds this picture to the incoming object.
----------------------------------------------------------------------------------
function Picture:Bind( picture )
    if picture == nil then
        slimui:err( 'Picture:Create failed to initialize a new object.' );
    end
    
    self._object = picture;
    
    return self;
end

----------------------------------------------------------------------------------
-- func: Picture:LoadFromFile
-- desc: Loads the given image file into this picture.
----------------------------------------------------------------------------------
function Picture:LoadFromFile( filename )
    picture_loadFromFile( self._object, filename );
end

----------------------------------------------------------------------------------
-- func: Picture:LoadFromStream
-- desc: Loads the given stream into this picture.
----------------------------------------------------------------------------------
function Picture:LoadFromStream( stream, ext )
    if ext == nil then
        picture_loadFromStream( self._object, stream );
    else
        picture_loadFromStream( self._object, stream, ext );
    end
end

----------------------------------------------------------------------------------
-- func: Picture:Assign
-- desc: Copies the source picture into this picture.
----------------------------------------------------------------------------------
function Picture:Assign( src )
    picture_assign( self._object, src );
end

----------------------------------------------------------------------------------
-- func: Picture:GetGraphic
-- desc: Returns the base graphic object of this picture.
----------------------------------------------------------------------------------
function Picture:GetGraphic( )
    return picture_getGraphic( self._object );
end



--[[ Debug information. ]]--------------------------------------------------------
if ( slimui:isdebug() == true ) then
    slimui:msg( '(Control) picture.lua successfully loaded.' );
end